<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>注册</title>
  <link rel="stylesheet" href="../css/register.css">
</head>
<script>
  function validateForm() {
    var password1 = document.getElementById('password1').value;
    var password2 = document.getElementById('password2').value;
    if (password1 !== password2) {
      alert("两次输入的密码不相同，请重新输入。");
      return false;
    }
    return true;
  }

  function goHome() {
    window.location.href = "http://localhost:8081/jsp/login.jsp"
  }
</script>
<body>
<h2 style="display: flex;justify-content: center;align-items: center">用户注册</h2>
<form action="/zelda/register" method="post" onsubmit="return validateForm()">
  <section>
    <label>
      <input id="username" type="text" name="username" placeholder="用户名">
    </label>
    <label>
      <input id="password1" type="password" name="password" placeholder="密码">
    </label>
    <label>
      <input id="password2" type="password" name="confirmPassword" placeholder="确认密码">
    </label>
    <button type="submit">注 册</button>
    <button type="button" class="registerBtn" onclick="goHome()">返回</button>
    <!-- 错误信息显示区域 -->
    <p style="color: red">
      ${error}
    </p>
  </section>
</form>
</body>
</html>